import axios from "/@/utils/http/axios";
import {MethodEnum} from "/@/utils/http/axios/enum/method-enum";
import {PageModel, TreeModel} from "/@/api/system/model/CommonModel";
import {UserModel, UserQueryModel} from "/@/api/system/model/UserModel";
import {UserRoleModel} from "/@/api/system/model/UserRoleModel";

/**
 * 修改当前用户密码
 */
export function updatePassword(params: object ,callBack?: Function) {
    return axios.httpRequest("/system/user/updatePassword", MethodEnum.POST, params, {callBack});
}
/**
 * 分页用户列表
 * @param isHint
 * @param callBack
 */
export function listUserPage(data: UserQueryModel,callBack?: Function):Promise<PageModel<UserModel[]>> {
    return axios.httpRequest("/system/user/listUserPage", MethodEnum.GET, data, {callBack});
}


/**
 * 新增用户
 * @param callBack
 */
export function insertUser(data: UserModel,callBack?: Function):Promise<void> {
    return axios.httpRequest("/system/user/insertUser", MethodEnum.POST, data, {callBack});
}

/**
 * 修改用户
 * @param callBack
 */
export function updateUser(data: UserModel,callBack?: Function):Promise<void> {
    return axios.httpRequest("/system/user/updateUser", MethodEnum.POST, data, {callBack});
}

/**
 * 根据用户id删除用户
 * @param data
 * @param callBack
 */
export function deleteUserByUserId(userId: string,callBack?: Function):Promise<void> {
    return axios.httpRequest("/system/user/deleteUserByUserId", MethodEnum.GET, {userId}, {callBack});
}

/**
 * 根据用户id查询用户
 * @param userId
 * @param callBack
 */
export function selectUserInfoByUserId(userId: string,callBack?: Function):Promise<UserModel> {
    return axios.httpRequest("/system/user/selectUserInfoByUserId", MethodEnum.GET, {userId}, {callBack});
}


/**
 * 批量保存用户职位关联
 * @param callBack
 */
export function saveUserPost(data: UserModel,callBack?: Function):Promise<void> {
    return axios.httpRequest("/system/user/saveUserPost", MethodEnum.POST, data, {callBack});
}
/**
 * 根据用户id查询用户职位关联
 * @param userId
 * @param callBack
 */
export function listUserPostByUserId(userId: string,callBack?: Function):Promise<UserModel> {
    return axios.httpRequest("/system/user/listUserPostByUserId", MethodEnum.GET, {userId}, {callBack});
}


/**
 * 批量保存用户角色关联
 * @param callBack
 */
export function saveUserRole(data: UserModel,callBack?: Function):Promise<void> {
    return axios.httpRequest("/system/user/saveUserRole", MethodEnum.POST, data, {callBack});
}

/**
 * 根据用户id查询用户角色关联
 * @param userId
 * @param callBack
 */
export function listUserRoleByUserId(userId: string,callBack?: Function):Promise<UserRoleModel[]> {
    return axios.httpRequest("/system/user/listUserRoleByUserId", MethodEnum.GET, {userId}, {callBack});
}

/**
 * 根据ordId查询用户树
 * @param orgId
 * @param callBack
 */
export function listUserTreeByOrgId(orgId: string,callBack?: Function):Promise<TreeModel[]> {
    return axios.httpRequest("/system/user/listUserTreeByOrgId", MethodEnum.GET, {orgId}, {callBack});
}